<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<title>天气预报</title>
</head>
<body>
	<input type="text" id="ipt" placeholder="请输入要查询的天气">
	<div>地方：<span id="city"></span></div>
	<div>天气：<span id="now"></span></div>
	<script>
		function loadXMLDoc(aa){
			var xmlhttp;
			if (window.XMLHttpRequest){
				//  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
				xmlhttp=new XMLHttpRequest();
			}else{
				// IE6, IE5 浏览器执行代码
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function(){
				if (xmlhttp.readyState==4 && xmlhttp.status==200){
					var json = xmlhttp.responseText;
					json = JSON.parse(json)
					console.log(json)
					document.querySelector("#city").innerHTML = json.basic.city
					document.querySelector("#now").innerHTML = json.now.cond.txt
				}
			}
			xmlhttp.open("GET","https://bird.ioliu.cn/weather?city="+aa,true);
			xmlhttp.send();
		}
		loadXMLDoc("吴桥")

		document.querySelector("#ipt").addEventListener("change",function(){
			loadXMLDoc(this.value);
		})
	</script>
</body>
</html>